package com.ruoyi.project.dict.eryapage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dict.eryapage.domain.EryaPage;
import com.ruoyi.project.dict.eryapage.service.IEryaPageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 尔雅页面Controller
 * 
 * @author shixiangwen
 * @date 2021-08-19
 */
@Controller
@RequestMapping("/dict/eryapage")
public class EryaPageController extends BaseController
{
    private String prefix = "dict/eryapage";

    @Autowired
    private IEryaPageService eryaPageService;

    @RequiresPermissions("dict:eryapage:view")
    @GetMapping()
    public String eryapage()
    {
        return prefix + "/eryapage";
    }

    /**
     * 查询尔雅页面列表
     */
    @RequiresPermissions("dict:eryapage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EryaPage eryaPage)
    {
        startPage();
        List<EryaPage> list = eryaPageService.selectEryaPageList(eryaPage);
        return getDataTable(list);
    }

    /**
     * 导出尔雅页面列表
     */
    @RequiresPermissions("dict:eryapage:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EryaPage eryaPage)
    {
        List<EryaPage> list = eryaPageService.selectEryaPageList(eryaPage);
        ExcelUtil<EryaPage> util = new ExcelUtil<EryaPage>(EryaPage.class);
        return util.exportExcel(list, "eryapage");
    }

    /**
     * 新增尔雅页面
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存尔雅页面
     */
    @RequiresPermissions("dict:eryapage:add")
    @Log(title = "尔雅页面", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(EryaPage eryaPage)
    {
        return toAjax(eryaPageService.insertEryaPage(eryaPage));
    }

    /**
     * 修改尔雅页面
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        EryaPage eryaPage = eryaPageService.selectEryaPageById(id);
        mmap.put("eryaPage", eryaPage);
        return prefix + "/edit";
    }

    /**
     * 修改保存尔雅页面
     */
    @RequiresPermissions("dict:eryapage:edit")
    @Log(title = "尔雅页面", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(EryaPage eryaPage)
    {
        return toAjax(eryaPageService.updateEryaPage(eryaPage));
    }

    /**
     * 删除尔雅页面
     */
    @RequiresPermissions("dict:eryapage:remove")
    @Log(title = "尔雅页面", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(eryaPageService.deleteEryaPageByIds(ids));
    }
}
